﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Swin_e_mon_Forms
{
    public abstract class GameEntity : IdentifiableObject
    {
        public GameEntity(string[] ids, bool isContainer)
            : base(ids)
        {
            if (isContainer)
            {
                _inv = new Inventory();
            }
        }

        private string _title, _Description;

        private Inventory _inv;

        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }

        public string Description
        {
            get { return _Description; }
            set { _Description = value; }
        }

        public Inventory Inventory
        {
            get { return _inv; }
        }

        public virtual string LongDescription
        {
            get 
            {
                if (HasInventory)
                    return Description + "\n\nInside the " + Title + " you can see:\n\n" + Inventory.ItemList;
                else
                    return Description;
            }
        }

        public bool HasInventory
        {
            get { return _inv != null; }
        }

        public virtual GameEntity LocateEntity(string id)
        {
            if (this.IdentifiedBy(id))
                return this;
            else if(HasInventory)
                return this.Inventory.AccessItem(id);
            return null;
        }
    }
}
